package com.hup.htts.model;

import com.hup.utils.commons.ListUtil;
import com.hup.utils.commons.io.BaseConfig;
import com.hup.utils.swing.model.BaseWindowConfig;
import lombok.Data;

import java.util.ArrayList;
import java.util.HashMap;

/**
 * @author hugan
 * @date 2021/9/12
 */
@Data
public class MainConfig implements BaseConfig<MainConfig> {

    public static final String HK_SPEAK = "speak";
    public static final String HK_STOP = "stop";

    public BaseWindowConfig windowConfig = new BaseWindowConfig();

    /**
     * 语音引擎index
     */
    public int voiceIndex = 0;
    /**
     * 语速
     */
    public int voiceSpeed = 3;

    /**
     * 自定义快捷键
     */
    public HashMap<String, ArrayList<Integer>> mapHotKey = new HashMap<>();

    @Override
    public boolean afterLoadFromFileOrReset(MainConfig fileConfig) {
        return fileConfig == null;
    }

    public ArrayList<Integer> getMapHotKey(String key) {
        return mapHotKey.get(key);
    }

    public void setHotKey(String key, ArrayList<Integer> hotKey) {
        if (ListUtil.nullOrEmpty(hotKey)) {
            mapHotKey.remove(key);
        } else {
            mapHotKey.put(key, new ArrayList<>(hotKey));
        }
    }

}
